// 相机类
#pragma once
#include <d3d9.h>
#include <d3dx9.h>

class Camera
{
public:
    Camera();
    ~Camera();

    void SetPosition(const D3DXVECTOR3& pos);
    void SetTarget(const D3DXVECTOR3& target);
    void SetUpVector(const D3DXVECTOR3& up);

    D3DXVECTOR3 GetPosition() const { return m_position; }
    D3DXVECTOR3 GetTarget() const { return m_target; }

    void SetPerspective(float fov, float aspect, float nearPlane, float farPlane);

    void UpdateMatrices(LPDIRECT3DDEVICE9 device);

    D3DXMATRIX GetViewMatrix() const { return m_matView; }
    D3DXMATRIX GetProjectionMatrix() const { return m_matProj; }

    // 键盘控制
    void ProcessInput(float deltaTime);
    void Move(const D3DXVECTOR3& offset);

    // 跟随玩家坦克
    void FollowTarget(const D3DXVECTOR3& targetPos, float targetYaw, float turretYaw, float deltaTime);
    void SetFollowMode(bool follow) { m_followMode = follow; }
    bool IsFollowMode() const { return m_followMode; }

private:
    D3DXVECTOR3 m_position;
    D3DXVECTOR3 m_target;
    D3DXVECTOR3 m_up;

    float m_fov;
    float m_aspect;
    float m_nearPlane;
    float m_farPlane;

    D3DXMATRIX m_matView;
    D3DXMATRIX m_matProj;

    bool m_followMode;
    D3DXVECTOR3 m_smoothPosition;  // For smooth camera movement
};
